#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include<QPainter>
#include<QPoint>
#include<QList>
#include<QtDebug>
#include<QPaintEvent>
#include<QMessageBox>
#define grid_side 20//格子边长
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
   void paintEvent(QPaintEvent *event);
   void keyPressEvent(QKeyEvent *event);
   void timerEvent(QTimerEvent *event);
private:
    Ui::MainWindow *ui;
    int direction;               // 蛇的方位1-上 2-下 3-左 4-右
    QPoint snakeHead;           //  蛇头
    QList<QPoint> foodList;    //   食物链表
    QList<QPoint> snakeList;  //    蛇链表
    bool isEat;
};
#endif // MAINWINDOW_H
